package com.yxhl.km.module.person.adapter;

import android.content.Context;
import android.util.DisplayMetrics;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.yxhl.km.R;
import com.yxhl.km.module.person.entity.ItemModel;
import com.yxhl.km.module.recycleradapter.ListBaseAdapter;
import com.yxhl.km.module.recycleradapter.SuperViewHolder;


/**
 * Created by Lzx on 2016/12/30.
 */

public class DataAdapter extends ListBaseAdapter<ItemModel> {
    private int width;

    public DataAdapter(Context context) {
        super(context);
        DisplayMetrics dm = context.getResources().getDisplayMetrics();
        width = dm.widthPixels;
    }

    @Override
    public int getLayoutId() {
        return R.layout.sample_item_text;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        ItemModel item = mDataList.get(position);
        TextView titleText = holder.getView(R.id.info_text);
        ImageView iv_icon = holder.getView(R.id.iv_icon);
        holder.getView(R.id.card_view).setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, width / 3));
        titleText.setText(item.title);
        iv_icon.setImageResource(item.Icon);
    }

    @Override
    public void onViewRecycled(SuperViewHolder holder) {
        super.onViewRecycled(holder);
    }

}
